import { ApiProp } from "src/decorator/swagger";
import { classDto2Zod } from "src/utils";
import { z } from "zod";

/** 代码异常表 */
export class CodeErrorDto {
  @ApiProp({ desc: 'id标识', zodType: z.number().int() })
  id!: number

  @ApiProp({ desc: '创建时间', zodType: z.date().or(z.string())
    .transform(date => (Object.prototype.toString.call(date)==='[object Date]') ? date: new Date(date) )
  })
  createTime!: Date

  @ApiProp({ desc: '更新时间', zodType: z.date().or(z.string())
    .transform(date => (Object.prototype.toString.call(date)==='[object Date]') ? date: new Date(date) )
  })
  updateTime!: Date

  @ApiProp({ desc: '用户账号', required: false, })
  account!: string

  @ApiProp({ desc: '当前标签页标识' })
  tabFlag!: string

  @ApiProp({ desc: '设备指纹' })
  fingerPrint!: string

  @ApiProp({ desc: '项目标识', zodType: z.number().int() })
  projectFlag!: number
  
  @ApiProp({ desc: '日志细分类型', zodType: z.number().int() })
  logType!: number


  @ApiProp({ desc: '当前用户所在url' })
  browserUrl!: string

  @ApiProp({ desc: '错误信息对应id', zodType: z.number().int() })
  messageId!: number

  @ApiProp({ desc: '出现次数', zodType: z.number().int() })
  times!: number
}

/** 代码异常表 */
export const CodeErrorZod = classDto2Zod(CodeErrorDto);
